<?php
/**
 * run with command
 * php start.php start
 */

namespace addons\human\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
use addons\human\library\Speech;
use addons\human\model\Job;
use think\Log;

/**
 *
 */
class Human extends Command
{

    protected function configure()
    {
        $this->setName('human')
            ->setHelp('此命令是用来实时更新虚拟人的任务进度')
            ->setDescription('虚拟人任务进度更细');
    }

    protected function execute(Input $input, Output $output)
    {
        $speech=new Speech;
        $list=Job::all(['status'=>'pending']);
        foreach ($list as $value) {
            $res=$speech->getSynthesis($value['job_id']);
            if($res['status']=='Succeeded'){
                $job=Job::get(['job_id'=>$value['job_id']]);
                $job->status='success';
                $job->output=$res['outputs']['result'];
                $job->save();
            }
            
        }
    }

    
}
